package WaiBao;

import java.util.Arrays;

public class ZhouYaHui {
    public static void main(String[] args) {
        String[] name = {"李翠花(班长)", "张翠兰(副班长)", "小李(学习委员)", "马德刚(文艺委员)", "里村铺", "龚小刚", "邓超", "王多鱼", "胡一菲", "张伟", "赵煜来", "吕子乔",
                "关谷神奇", "唐悠悠", "李武奇", "陈美嘉", "小黑", "小白", "小灰灰", "喜洋洋", "美羊羊", "沸羊羊", "村长", "灰太狼", "红太狼", "懒洋洋", "雷军", "王磊",
                "杨洋", "周雅慧(学生)"};//考生本人: 周雅慧(学生)
        int[] age = {19, 22, 19, 19, 19, 21, 19, 21, 19, 19, 18, 20, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 19};//考生年龄：19

        double[] EFR1 = {88, 82, 64, 90, 68, 69, 78, 89, 80, 90, 91, 87, 85, 79, 65, 78, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 74, 80, 96};
        double[] EFR2 = {68, 65, 69, 86, 74, 67, 88, 77, 90, 90, 90, 77, 86, 78, 65, 65, 86, 79, 65, 78, 92, 71, 95, 85, 75, 84, 84, 64, 90, 94};
        double[] EFR3 = {71, 96, 80, 95, 79, 69, 78, 69, 80, 60, 93, 87, 85, 75, 64, 68, 69, 69, 86, 93, 92, 81, 95, 95, 76, 84, 73, 71, 89, 94};



        double huhu1;//代表每个学生的总分
        double huhu2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            huhu1 = EFR1[i] + EFR2[i] + EFR3[i];
//            huhu2 = (huhu1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + huhu1);
//            System.out.println(name[i] + "的平均分为:" + huhu2);
//        }

        double fgt1 = 0, fgt2 = 0;
        double[] ght = new double[30];
//        for (int i = 0; i < 30; i++) {
//            fgt1 = EFR1[i] + EFR2[i] + EFR3[i];
//            fgt2 = (fgt1 * 1.0) / 3;
//            ght[i] =fgt2;
//        }
//
//        for (int i = 0; i < ght.length - 1; i++) {
//            for (int j = 0; j < ght.length - i - 1; j++) {
//                if (ght[j] < ght[j + 1]) {
//                    double tep = ght[j];
//                    ght[j] = ght[j + 1];
//                    ght[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(ght[i]);
//        }



        double chayu1 = 0, chayu2 = 0,chayu3 = 0;//计算每门课的平均分
        double xinsi1 = 0,xinsi2 = 0, xinsi3 = 0;//计算每门课标准差
        double dafa1 = 0, dafa2 = 0, dafa3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <EFR1.length; i++) {
            he +=EFR1[i];
        }
        chayu1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + chayu1);
        double Sum = 0;
        for (int i = 0; i <EFR2.length; i++) {
            Sum += EFR2[i];
        }
        chayu2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + chayu2);
        double sum = 0;
        for (int i = 0; i < EFR3.length; i++) {
            sum += EFR3[i];
        }
        chayu3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + chayu3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <EFR1.length; i++) {
            c1 += (EFR1[i] - chayu1) *( EFR1[i] - chayu1);
        }
        xinsi1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + xinsi1);
        for (int i = 0; i <EFR2.length; i++) {
            c2 += (EFR2[i] -chayu2) * (EFR2[i] -chayu2);
        }
        xinsi2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + xinsi2);

        for (int i = 0; i < EFR3.length; i++) {
            c3 += (EFR3[i] - chayu3) * (EFR3[i] -chayu3);
        }
        xinsi3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + xinsi3);
////////
//////
//////
        Arrays.sort(EFR1);
        Arrays.sort(EFR2);
        Arrays.sort(EFR3);
        dafa1 = (EFR1[14] + EFR2[15]) * 1.0 / 2;
        dafa2 = (EFR2[14] + EFR2[15]) * 1.0 / 2;
        dafa3 = (EFR3[14] + EFR3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + dafa1);
        System.out.println("物理化学的中位数为:" + dafa2);
        System.out.println("电子与电工技术的中位数为:" + dafa3);




    }
}
